<?php
/**
 * YICMS
 * ============================================================================
 * 版权所有 2014-2017 YICMS，并保留所有权利。
 * 网站地址: http://www.yicms.vip
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * Created by PhpStorm.
 * Author: kenuo
 * Date: 2017/11/13
 * Time: 上午10:35
 */

namespace App\Repositories;


use App\Models\Config\Channels;
use App\Models\Config\Games;
use App\Models\Role;
use App\Models\Rule;

class RolesRepository extends BaseRepository
{
    public function __construct(Role $model)
    {
        $this->model = $model;
    }

    /**
     * 获取所有角色
     * @return mixed
     */
    public function getRoles()
    {
        return Role::get();
    }

    public function getGames()
    {
        return Games::query()->where(['game_id' => session('game_id')])->get();
    }

    public function getChannels()
    {
        return Channels::orderBy('sort', 'asc')->get();
    }

    public function getPage($request)
    {
        $pageSize = 10;
        $query = Role::query();
        if (!empty($request->get('page_size'))) {
            $pageSize = $request->get('page_size');
        }
        return $query->latest('id')->paginate($pageSize);
    }
}